#!/bin/sh
if [ "${USE_DNS_CACHE-}" = true ]; then
    cp /etc/resolv.conf /etc/resolv.dnsmasq
    if [ "${LOG_DNS_QUERIES-}" = true ]; then
        echo "log-queries=extra" >> /etc/dnsmasq.d/fix.conf
    fi
    dnsmasq
    echo "nameserver 127.0.0.1" > /etc/resolv.conf
fi
if [ -n "${CRONTAB-}" ]; then
    echo -e "$CRONTAB" > "/etc/crontabs/$(whoami)"
fi
if [ "${USE_CROND-}" = true ]; then
    : "${LOGFILE:=/var/log/fix.log}"
    touch "$LOGFILE"
    crond
    exec tail -F "$LOGFILE"
else
    exec fix "$@"
fi
